package com.fmjava.service_upload.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/*
 *@ClassName AppConfig
 *@Description TODO
 *@Author 吃麻椒的花酱
 *@Date 2021/7/7 15:43
 *@Version 1.0
 */
@Configuration
@ConfigurationProperties(prefix = "spring.oss")
@Data
public class AppConfig implements InitializingBean {
   String endpoint;
   String accessKeyId;
   String accessKeySecret;
   String bucketName;

    public static String ENDPOINT;
    public static String ASSESS_KEY_ID;
    public static String ASSESS_KEY_SECRET;
    public static String BUCKET_NAME;

    /*在属性文件加载完毕后属性也设置完毕之后, 会自动调用*/
    @Override
    public void afterPropertiesSet() throws Exception {
        ENDPOINT = endpoint;
        ASSESS_KEY_ID = accessKeyId;
        ASSESS_KEY_SECRET = accessKeySecret;
        BUCKET_NAME = bucketName;
    }
}
